
export default function wxRequest(config) {
	return new Promise((resolve, reject) => {
		const {
			url,
			method,
			data,
			params,
			timeout,
			headers: header,
			dataType = 'json',
			responseType = 'text',
			cancelToken
    } = config
		const requestTask = wx.request({
			url,
			method,
			data,
			header,
			timeout,
			dataType,
			responseType,
			success: res => resolve(res),
			fail: err => reject(err),
			complete: () => { }
		})
		if (cancelToken) {
			cancelToken.promise.then(reason => {
				requestTask.abort()
				reject(reason)
			})
		}
	})
}